package com.jinke.api.modules.third.shipber.model.request;

import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;
import java.util.List;

@Data
public class CreateOrderRequest {

    @JsonProperty("custom_order_num")
    private String customOrderNum;
    @JsonProperty("shipment")
    private Shipment shipment;
    @Data
    public static class Shipment {
        @ApiModelProperty("货运商编码")
        private String carrier;
        @ApiModelProperty("运输服务编码")
        private String serviceCode;
        @JsonProperty("ship_from")
        private ShipFrom shipFrom;
        @JsonProperty("ship_to")
        private ShipTo shipTo;
        private List<Package> packages;
        @JsonProperty("package_type")
        private PackageType packageType;
        @JsonProperty("label_specification")
        private LabelSpecification labelSpecification;
        @JsonProperty("pickup_date")
        private String pickupDate;
    }
    @Data
    public static class ShipFrom {
        private String uuid;
    }

    @Data
    public static class ShipTo {
        private String city;
        private String name;
        private List<String> addresses;
        @JsonProperty("postal_code")
        private String postalCode;
        @JsonProperty("country_code")
        private String countryCode;
        @JsonProperty("state_province_code")
        private String stateProvinceCode;
        private String phone;
        @JsonProperty("is_residential")
        private Boolean isResidential;
    }

    @Data
    public static class Package {
        private Dimension dimension;
        private Weight weight;
        private String confirmation;
        private Insurance insurance;
        private Integer quantity;

        @JsonProperty("reference_numbers")
        private List<ReferenceNumber> referenceNumbers;
    }

    @Data
    public static class Dimension {
        private BigDecimal width;
        private BigDecimal height;
        private BigDecimal length;
        private String code;
    }

    @Data
    public static class Weight {
        private String code;
        private BigDecimal value;
    }

    @Data

    public static class Insurance {
        private String code;
        private int value;
    }

    @Data
    public static class ReferenceNumber {
        private String code;
        private String value;
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class PackageType {
        private String type;
        private String name;
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class LabelSpecification {
        @JsonProperty("label_format")
        private String labelFormat;
    }
}